package com.sq.shortlink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sq.shortlink.project.dao.entity.ShortLinkDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 短链接持久层
 * @author quan
 */
@Mapper
public interface ShortLinkMapper extends BaseMapper<ShortLinkDO> {

    @Update("update t_link set total_pv = total_pv + #{totalPv},total_uv = total_uv + #{totalUv},total_uip = total_uip + #{totalUip},update_time = now() where full_short_url = #{fullShortUrl} and gid = #{gid}")
    void incrementStats(@Param("fullShortUrl") String fullShortUrl,
                        @Param("gid") String gid,
                        @Param("totalPv") Integer totalPv,
                        @Param("totalUv") Integer totalUv,
                        @Param("totalUip") Integer totalUip
                        );
}
